#pragma once

#include <assert.h>

#include "color.h"
#include "Vector2D.h"
#include "VectorContainer.h"
#include "SpriteAsset.h"

/*************************************************************************************************************************************************************/
/* The Graphics class will be responsible for and be able to handle drawing 2D sprites
/* The process for doing this will be to access the drawlist that contains all the objects
/* Graphics will have no duties other than managing drawing objects to the screen, therefore things like sound, input, game logic should *never* go here
/* This module should be private and all of its abilities limited to working through an Engine
/*
/* -Michael Alstad
/*************************************************************************************************************************************************************/
class Graphics
{
public:
	/* Prototypes for public functions */
	Graphics();						// unlike previous iterations, this module will not be a singleton
	bool Init(HWND hWnd);

	/**
	 * Adds a sprite or spritesheet to list of assets
	 * @param cszFileName	the file name of the image being used
	 * @param pColorKey		allows for background of spritesheet to be given an alpha color, specify NULL for no color key
	 * @param iBlitFrames	number of frames for that sprite's animation, specificy 1 for no animation
	 */
	int			AddSpriteAsset(const char* cszFileName, color* pColorKey, int iBlitFrames);							
	bool		RemoveSpriteAsset(int assetID);
	Vector2D	GetAssetDimensions(int assetID);
	void Update();
	void Render();
	void Release();
	~Graphics();

private:
	/* Declaration of Member variables of Graphics */
	IDirect3DDevice9*		m_pD3DDevice;				// the main drawing device
	ID3DXFont*				m_pFontManager;				// for drawing text to the screen
	ID3DXSprite*			m_pSpriteManager;			// for drawing sprites to the screen
	D3DPRESENT_PARAMETERS	m_D3Dpp;					// presentation parameters to be setup in Init()
	HWND					m_hWnd;						// a copy of hWnd from main for initialization
	int						m_iHeight, m_iWidth;		// a copy of the main window's dimensions
	bool					m_bInitialized;				// indicates whether Init() has been called previously
	bool					m_bInitFailed;				// indicates whether Init() returned false
	bool					m_bWindowed;				// fullscreen = false

	/* Sub-functions of the main Init() */
	bool InitDevice(HWND hWnd);
	bool InitManagers();

	/* Sub-function of Render */
	void DrawWorld();
	void DrawObject(/*BaseObject* pObj*/);
	//void Draw3D(Vector3D a_trans, Vector3D a_rot, Vector3D a_scale, GameAsset asset);
	//D3DXMATRIX CreateWorldMatrix(Vector3D a_trans, Vector3D a_rot, Vector3D a_scale);
	//void DrawGUI(gui_panel* guiObj, GameAsset asset);

	/* Sub-functions used to load from files */
	void LoadMeshFromFile(const char* cszFileName, ID3DXMesh* & pMesh);
	void LoadTextureFromFile(const char* cszFileName, color* cKey, IDirect3DTexture9* & pTex);
};